package com.fstrat.frontend.webserviceclient;

import java.util.List;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;



import com.fstrat.backend.entities.Angebot;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.util.MultivaluedMapImpl;

import sun.reflect.generics.reflectiveObjects.NotImplementedException;


public class AngebotClient {

	static public Angebot findeAngebot(long angebotId)
	{
		MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
		queryParams.add("id", String.valueOf(angebotId));
		WebResource webResource = WebResourceFactory.getAngebotInstance();	
		Angebot angebot = webResource.queryParams(queryParams)
									.accept(MediaType.APPLICATION_JSON_TYPE)
									.get(Angebot.class);
		return angebot;
	}
	
	static public Boolean schreibeAngebot(Angebot angebot)
	{
		WebResource webResource = WebResourceFactory.getAngebotInstance();
		Boolean istGespeichert = webResource.type(MediaType.APPLICATION_JSON_TYPE)
									.accept(MediaType.APPLICATION_JSON_TYPE)
									.post(Boolean.class, angebot);
		return istGespeichert;
	}
	static public List<Angebot> holeAlleAngebote()
	{		
		WebResource webResource = WebResourceFactory.getAngebotInstance();
		List<Angebot> aList 	= webResource.path("alle")
								.accept(MediaType.APPLICATION_JSON_TYPE)
								.post(new GenericType<List<Angebot>>() {
								});
		return aList;
	}
	
	
	static List<Angebot> findeAngebote(long benutzerId)
	{
		throw new NotImplementedException();
	}
	
	static Boolean bearbeiteAngebot(Angebot angebot)
	{
		throw new NotImplementedException();
	}
	
	
}
